package jwf.fcgi;

import java.io.IOException;
import java.io.InputStream;

public class FCGXStdin {

    public static String makeStdin(InputStream in, FCGXHeader header)
	    throws IOException {
	int len = header.getContentLength() + header.getPaddingLength();
	byte[] stdinBuff = new byte[len];
	int l = in.read(stdinBuff, 0, len);
	if (l != len) {
	    return "";
	}

	String v = "";
	if (header.getContentLength() != 0) {
	    v = new String(stdinBuff, 0, header.getContentLength());
	}
	return v;

    }
}
